import {productAction, cateAction} from '../funnames'
import fly from '../../net/flyio'
import url from '../../net/serverurl'
import Arrayutils from '../../utils/arrayutils'
import cclong from '../../utils/globalfun'

const state = {
  productList: [],
  errorPage: false,
  errorMsg: '很抱歉，暂无数据'
}

const mutations = {
  [productAction.ACTION_PRODUCT_LIST](state, {data}) {
    if (data.successCode) {
      if (cclong.isArrayEmpty(data.data)){

      }
      state.productList = data.data
      state.errorPage = false
      state.errorMsg = '很抱歉，暂无数据'
    } else {
      state.errorPage = true
      state.errorMsg = data.message
      cclong.showLongToast(data.message)
    }
  }
}

const actions = {
  async getProductList({commit, dispatch, state, rootState}) {
    console.log(rootState)
    console.log(state)
    dispatch(cateAction.ACTION_TEST, null, {root: true})
  }
}

export default {
  state,
  mutations,
  actions
}
